
Partial Class MasterPage
    Inherits System.Web.UI.MasterPage

    Private _Empire As OGame.Empire

    Public ReadOnly Property Empire() As OGame.Empire
        Get
            Return _Empire
        End Get
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sd As SessionData = Session(SessionData.VARIABLE_NAME)

        If sd Is Nothing Then
            Response.Redirect(SiteMap.LOGIN_PAGE)
        End If

        Try
            _Empire = OGame.GetEmpire(sd.ServerName, sd.UserName, sd.Password)
        Catch ex As Exception
            Session(SessionData.VARIABLE_NAME) = Nothing
            If TypeOf Parent Is UserPage Then
                CType(Parent, UserPage).Exception = ex
            End If
            Server.Transfer(SiteMap.ERROR_PAGE)
        End Try

        If _Empire IsNot Nothing Then
            HyperLink1.NavigateUrl = _Empire.GetUrl()
        End If
    End Sub
End Class

